package net.osweb.core.tools.utils;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class UploadFile {
	public static boolean uploadFile(File file, String fileName, String filePath){
		
		BufferedOutputStream out = null;
		BufferedInputStream in = null;		
		try {
			in = new BufferedInputStream(new FileInputStream(file));
	//		File file_imp = new File(filePath + fileName);
			out = new BufferedOutputStream(new FileOutputStream(filePath+"\\"+fileName));
			byte[] buffer = new byte[1024 * 8];
			int i = -1;
			while ((i = in.read(buffer)) != -1) {
				out.write(buffer, 0, i);
			}
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			return false;

		} finally {
			try {
				if (in != null)
					in.close();
				if (out != null)
					out.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}	
		return true;
	}
}
